home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / scrasm / modex.inc < prev    next >
Text File  |  1993-03-08  |  4KB  |  88 lines

  1. ; ====================================================================
  2. ; Entry points:
  3. ; ====================================================================
  4. MODEX_START     MACRO
  5.                 mov     ax,13h  ;let the BIOS set standard 256-color
  6.                 int     10h     ; mode (320x200 linear)
  7. ;               PALETTE_BLACK
  8.                 call    ModifyForX
  9.                 ENDM
  10.  
  11. ; ====================================================================
  12. ; This is MODE-X code from Dr. Dobb's Journal, by Michael Abrash.
  13. ; I modified it from 320x240 back to 320x200, and then to 512 virtual
  14. ; width, for scrolling purposes.
  15. ; ====================================================================
  16.  
  17. ; Mode X (320x240, 256 colors) mode set routine. Works on all VGAs.
  18. ; ****************************************************************
  19. ; * Revised 6/19/91 to select correct clock; fixes vertical roll *
  20. ; * problems on fixed-frequency (IBM 851X-type) monitors.        *
  21. ; ****************************************************************
  22. ; Modified from public-domain mode set code by John Bridges.
  23.  
  24. ; Index/data pairs for CRT Controller registers that differ between
  25. ; mode 13h and mode X.
  26. CRTParms label  word
  27. ;       dw      00d06h  ;vertical total
  28. ;       dw      03e07h  ;overflow (bit 8 of vertical counts)
  29. ;       dw      04109h  ;cell height (2 to double-scan)
  30. ;       dw      0ea10h  ;v sync start
  31. ;       dw      0ac11h  ;v sync end and protect cr0-cr7
  32. ;       dw      0df12h  ;vertical displayed = 480
  33.         dw      00014h  ;turn off dword mode                    *
  34. ;       dw      0e715h  ;v blank start
  35. ;       dw      00616h  ;v blank end
  36.         dw      0e317h  ;turn on byte mode                      *
  37.  
  38.         dw      (VIRTUAL_WIDTH*32)+13h  ; width of screen = VWid   NEW
  39. ;       dw      09012h  ;vertical displayed = 400 (already like this)
  40. CRT_PARM_LENGTH equ     (($-CRTParms)/2)
  41.  
  42. ModifyForX      PROC    near
  43.                 mov     dx,SC_INDEX
  44.                 mov     ax,0604h
  45.                 out     dx,ax           ;disable chain4 mode
  46.                 mov     ax,0100h
  47.                 out     dx,ax           ;synchronous reset while setting Misc
  48.                                         ; Output for safety, even though clock
  49.                                         ; unchanged
  50.                 mov     dx,MISC_OUTPUT
  51.                 mov     al,0e3h
  52.                 out     dx,al           ;select 25 MHz dot clock & 60 Hz scanning rate
  53.  
  54.                 mov     dx,SC_INDEX
  55.                 mov     ax,0300h
  56.                 out     dx,ax           ;undo reset (restart sequencer)
  57.  
  58.                 mov     dx,CRTC_INDEX   ;reprogram the CRT Controller
  59.                 mov     al,11h          ;VSync End reg contains register write
  60.                 out     dx,al           ; protect bit
  61.                 inc     dx              ;CRT Controller Data register
  62.                 in      al,dx           ;get current VSync End register setting
  63.                 and     al,7fh          ;remove write protect on various
  64.                 out     dx,al           ; CRTC registers
  65.                 dec     dx              ;CRT Controller Index
  66.                 cld
  67.                 push    cs
  68.                 pop     ds
  69.                 mov     si,offset CRTParms ;point to CRT parameter table
  70.                 mov     cx,CRT_PARM_LENGTH ;# of table entries
  71. SetCRTParmsLoop:
  72.                 lodsw                   ;get the next CRT Index/Data pair
  73.                 out     dx,ax           ;set the next CRT Index/Data pair
  74.                 loop    SetCRTParmsLoop
  75.  
  76.                 mov     dx,SC_INDEX
  77.                 mov     ax,0f02h
  78.                 out     dx,ax           ;enable writes to all four planes
  79.                 mov     ax,SCREEN_SEG   ;now clear all display memory, 8 pixels
  80.                 mov     es,ax           ; at a time
  81.                 sub     di,di           ;point ES:DI to display memory
  82.                 sub     ax,ax           ;clear to zero-value pixels
  83.                 mov     cx,8000h        ;# of words in display memory
  84.             rep stosw                   ;clear all of display memory
  85.  
  86.                 ret
  87. ModifyForX      ENDP
  88.